Release 10.1A: OpenEdge Development:
Programming Interfaces
Setting byte order
When passing
MEMPTRdata between system environments (such as can happen using sockets), you must help ensure that the communicating applications agree on the byte order for any data types that are transferred using theMEMPTRvariable. Most machines follow one of two schemes for ordering bytes:
- Little-endian — Low-order bytes are stored starting at the lowest address location reserved for a data type, with progressively higher-order bytes stored at the higher byte positions. For example, 7 is stored in a four-byte (hex) integer as follows, where addresses increase from left to right:
- Big-endian — High-order bytes are stored in the lowest address location reserved for a data type with progressively lower-order bytes stored at the higher byte positions. For example, 7 is stored in a four-byte (hex) integer as follows, where addresses increase from left to right:
Progress ensures that
MEMPTRdata is interpreted correctly usingMEMPTRwrite/read statements and functions as long as you indicate what byte order theMEMPTRdata that you write uses. You can do this using theSET-BYTE-ORDERstatement:
Given the name of the
MEMPTRvariable (memptr-name), you can set one of these keyword values forinteger-expression:
HOST-BYTE-ORDER— A value of one (1) that indicates the byte ordering of the machine where the statement executes.Note: Internet protocols use big-endian byte ordering.BIG-ENDIAN— A value of two (2) that indicates big-endian byte ordering.LITTLE-ENDIAN— A value of three (3) that indicates little-endian byte ordering.By default, all
MEMPTRvariables use the byte ordering of the machine where they are defined.Note that the
SET-BYTE-ORDERstatement does not change the existing order of bytes in theMEMPTRdata. It only indicates how subsequentMEMPTRwrite/read statements and functions interpret the data. You can also return the current byte order setting using theGET-BYTE-ORDERfunction. For more information, see the OpenEdge Development: Progress 4GL Reference .
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |